<% if @current_user.administrator && !@users_pending_validation.empty? %>
  <h2>Users pending validation</h2>
  <table>
    <tr>
      <th>ID</th>
      <th>Username</th>
      <th>Email</th>
      <th>Administrator</th>
      <th>Validated</th>
      <th>Created at</th>
      <th>Last Updated</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>

    <% @users_pending_validation.each do |user| %>
      <tr>
        <td><%= user.id %></td>
        <td><%= link_to user.username, user %></td>
        <td><%= user.email %></td>
        <td><%  display_true_false_field(user.administrator) %></td>
        <td><%  display_true_false_field(user.validated) %></td>
        <td><%= user.created_at.to_formatted_s(:short) %></td>
        <td><%= user.updated_at.to_formatted_s(:short) %></td>
        <td><%= link_to 'Show', user %></td>
        <td><%= link_to 'Validate', validate_user_path(user) %></td>
        <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
      </tr>
    <% end %>
  </table>
  <br />
  <h2>List of Users</h2>
<% end %>

<table>
  <tr>
    <th>ID</th>
    <th>Username</th>
    <th>Email</th>
    <th>Administrator</th>
    <th>Validated</th>
    <th>Created at</th>
    <th>Last Updated</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

  <% @users.each do |user| %>
    <tr>
      <td><%= user.id %></td>
      <td><%= link_to user.username, user %></td>
      <td><%= user.email%></td>
      <td><%  display_true_false_field(user.administrator) %></td>
      <td><%  display_true_false_field(user.validated) %></td>
      <td><%= user.created_at.to_formatted_s(:short) %></td>
      <td><%= user.updated_at.to_formatted_s(:short) %></td>
      <td><%= link_to 'Show', user %></td>
      <td><%= link_to 'Edit', edit_user_path(user) %></td>
      <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
    </tr>
  <% end %>
</table>

<br />

<%= link_to 'New User', new_user_path %>
